package com.lbssoft.gpsbd.dao;

import com.lbssoft.gpsbd.model.Log;
import com.lbssoft.gpsbd.model.LoginLog;
import com.lbssoft.gpsbd.model.Role;
import com.lbssoft.gpsbd.model.vo.RoleVo;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface LogMapper {

	/**
	 * 写入日志
	 * @param log
     */
	@Insert("INSERT INTO lbs_logs ( userId, account, action, targetType, params, remark,result, ip,status ) VALUE ( #{userId}, #{account}, #{action}, #{targetType}, #{params}, #{remark}, #{result}, #{ip}, #{status} )")
	void add(Log log);

	/**
	 * 获取系统日志
	 * @return
     */
	@Select("SELECT * FROM lbs_logs ${where} order by id desc")
	List<Log> list(@Param("where") String where);

	/**
	 * 写入登录日志
	 * @param log
     */
	@Insert("INSERT INTO lbs_logs_login(userId,ip,client) VALUE(#{userId},#{ip},#{client})")
	void addLoginLog(LoginLog log);

	/**
	 * 获取登录日志
	 * @return
	 */
	@Select("SELECT * FROM lbs_logs_login where userId = #{userId} order by id desc")
	List<LoginLog> loginList(@Param("userId") long userId);
}
